/*
 **********************************************************************
 * Copyright (c) 2013 Kernull.com
 * 
 * All rights reserved. No warranty, explicit or implicit, provided.
 * 
 * @author 	Christopher Aprea <caprea@kernull.com>
 * @date 	Oct 9, 2013
 * @project javapoker
 * 
 * Class intended to keep a collection of the credits contributed by the players
 * as well as a history of the actions that contributed credits
 * ==================================================================
 * This software is provided by the copyright holders and contributors "as
 * is" and any express or implied warranties, including, but not limited to,
 * the implied warranties of merchantability and fitness for a particular
 * purpose are disclaimed.  in no event shall the copyright owner or
 * contributors be liable for any direct, indirect, incidental, special,
 * exemplary, or consequential damages (including, but not limited to,
 * procurement of substitute goods or services; loss of use, data, or
 * profits; or business interruption) however caused and on any theory of
 * liability, whether in contract, strict liability, or tort (including
 * negligence or otherwise) arising in any way out of the use of this
 * software, even if advised of the possibility of such damage.
 **********************************************************************
 */
package javapoker;

import java.util.ArrayList;
import java.util.HashMap;

public class Pot  
{
	
	private long _littleBlind = 0;
	private long _total = 0;
	private HashMap<Player, Boolean> paidin;
	private ArrayList<Action> _history = new ArrayList<Action>();
	private long _bigBlind = 0;
	
	
	public Pot() 
	{
		this(0);
	}

	public Pot(long lilBlind)
	{
		paidin = new HashMap<Player, Boolean>();
		_littleBlind = lilBlind;
		_bigBlind  = _littleBlind * 2;
	}
	
	public void reset()
	{
		_total = 0;
	}

	public void contribute(Player p, long amount)
	{
		paidin.put(p, true);
		p.subtract(amount);
		_total += amount;
	}
	
	public void addLittleBlind(Player p)
	{
		contribute(p, _littleBlind);
	}
	
	public void addBigBlind(Player p)
	{
		contribute(p, _bigBlind);
	}

	public void payWinner(Player winner) 
	{
		winner.add(_total);
		_total = 0;
	}

	/**
	 * Determiend whether player paid into this pot and is playing this round
	 * @param player
	 * @return
	 */
	public boolean isPlaying(Player player) 
	{
		if ( paidin.containsKey(player))
		{
			return true;
		}
		return false;
	}
	
	

}
